﻿using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 多配置源的优先级
{
    internal class GetConfigController
    {
        private readonly IOptionsSnapshot<Config> _optConfig;
        public GetConfigController(IOptionsSnapshot<Config> optConfig)
        {
            _optConfig = optConfig;
        }

        public void PrintConfig()
        {
            Config config = _optConfig.Value;
            Console.WriteLine($"name = {config.Name}");
            Console.WriteLine($"age = {config.Age}");
            Console.WriteLine($"proxy:ip = {config.Proxy.IP}");
            Console.WriteLine($"proxy:port = {config.Proxy.Port}");           
        }
    }
}
